#include "DFT.hpp"
#include <cmath>

std::complex<double> dft(int n,const double *data,unsigned int data_length){
    if ( data == nullptr ){
        return 0;
    }
    double real = 0.0;
    double imag = 0.0;
    double k = 0.0;
    for ( int m = 0; m < data_length; m++ ){
        k = 2 * M_PI * n / data_length;
        real += data[m] * cos(k * m);
        imag += -1 * data[m] * sin(k * m);
    }
    std::complex<double> ret(real,imag);
    return ret;
}